print("--array--")
a = {}
for i=1,10 do
    a[i] = 0
end
print(a[10], "\n")

print("--matrix--")
mt = {}
for i=1,2 do
    mt[i] = {}
    for j=1,2 do
        mt[i][j] = 0
    end
end
print(mt[2][2], "\n")

print("--list--")
list = nil
list = {next = list, value = "value"}
local l = list
while l do
    print(l.value)
    l = l.next
end
print("\n")

print("--queue--")
queue = {}

function queue.new()
    return {first = 0, last = -1}
end

function queue.pushleft(queue, value)
    local first = queue.first - 1
    queue.first = first
    queue[first] = value
end

function queue.pushright(queue, value)
    local last = queue.last + 1
    queue.last = last
    queue[last] = value
end

function queue.popleft(queue)
    local first = queue.first
    if first > queue.last then error("queue is empty") end
    local value = queue[first]
    queue[first] = nil
    queue.first = first + 1
    return value
end

function queue.popright(queue)
    local last = queue.last
    if queue.first > last then error("queue is empty") end
    local value = queue[last]
    queue[last] = nil
    queue.last = last - 1
    return value
end

print("--set--")
function Set(list)
    local set = {}
    for _, l in ipairs(list) do set[l] = true end
    return set
end
reserved = Set{"while", "end", "local",}
table.foreach(reserved, print)
print("\n")
